package cn.mw.cmdb.task;

import cn.mw.cmdb.entity.AssetsDiscoverInfo;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AssetsDiscoveryStatusRefreshTask implements Runnable{
    private AssetsDiscoveryRunManage runManage;

    private AssetsDiscoverInfo assetsDiscoverInfo;

    public AssetsDiscoveryStatusRefreshTask(AssetsDiscoveryRunManage runManage ,AssetsDiscoverInfo assetsDiscoverInfo){
        this.runManage = runManage;
        this.assetsDiscoverInfo = assetsDiscoverInfo;
    }

    @Override
    public void run() {
        while (true){
            if(Thread.currentThread().isInterrupted()){
                break;
            }
            if(null != runManage){
                runManage.refreshExpireTime(assetsDiscoverInfo);
            }

            try {
                Thread.sleep(5000);
            }catch (InterruptedException interruptedException){
                break;
            }catch (Exception e){
                log.error("AssetsDiscoveryStatusRefreshTask" ,e);
            }
        }
    }
}
